﻿Imports iTextSharp
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Imports iTextSharp.text.xml
Imports System.Collections
Imports System.Text
Public Class PdfTemplateInfo
    Public ExportedFileName As String
    Public FileLocation As String
    Public DestinationPath As String
    Public FieldList As List(Of String)
    Public FieldDict As Dictionary(Of String, String)

    Public Sub New(ByVal PdfFormLocation As String, ByVal ExportFileName As String, ByVal ExportDestination As String)
        ReadFormFields(PdfFormLocation)
        ExportedFileName = ExportFileName
        DestinationPath = ExportDestination
        FileLocation = PdfFormLocation
    End Sub

    Private Sub ReadFormFields(ByVal PdfFormLocation As String)
        Dim PdfReader As PdfReader

        Try
            PdfReader = New PdfReader(PdfFormLocation)
            FieldList = New List(Of String)
            For Each PdfField As String In PdfReader.AcroFields.Fields.Keys
                FieldList.Add(PdfField)
            Next

        Catch ex As Exception
            MsgBox("Error in ReadTemplate: " & ex.Message, MsgBoxStyle.Critical, "Error")
        End Try
    End Sub
End Class
